package com.zlll.winner.mapper.bbs;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zlll.winner.business.model.bbs.BbsSubject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zlll.winner.business.vo.bbs.BbsPostVo;
import com.zlll.winner.business.vo.bbs.BbsSubjectVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 论坛频道话题表 Mapper 接口
 * </p>
 *
 * @author Walert
 * @since 2019-09-12
 */
public interface BbsSubjectMapper extends BaseMapper<BbsSubject> {

    @Select("select " +
            "t.* " +
            "from bbs_subject t " +
            "left join bbs_subject_city m1 on (t.id = m1.subject_id and m1.is_del = 0) " +
            "${ew.customSqlSegment} group by t.id " +
            "order by t.create_time desc")
    IPage<BbsSubjectVo> selectPageByCustomer(IPage<BbsSubjectVo> page, @Param("ew") Wrapper<BbsSubjectVo> queryWrapper);

    @Select("select " +
            "t.* " +
            "from bbs_subject t " +
            "left join bbs_subject_city m1 on (t.id = m1.subject_id and m1.is_del = 0) " +
            "${ew.customSqlSegment} " +
            "group by t.id " +
            "order by t.create_time desc ")
    List<BbsSubject> getSubjectInfoByPositionAndCity(@Param("ew") Wrapper<BbsSubject> queryWrapper);

}
